<?php
class Application_Form_Zone extends Exts_Form {
	
	public static function newCreateForm(){
	   $form = Application_Form_Zone::newUpdateForm();
	   return $form;
	}
    public static function newUpdateForm(){
    	
        $form = new Application_Form_Zone();
        $form->addElement('text', 'name', array(
            'required'   => true,
            'validators' => array(
            ),
            'class' => 'sf'
        ));

        $form->addElement("hidden", "parent_id");
       	$form->addElement("hidden", "zone_id");
       	$form->addElement("text", "parentText", array("readonly" => "readonly"));
       	 
        $form->setDecorators(
            array(
                array(
                    'ViewScript',
                    array( 'viewScript' => 'zone/form.phtml' )
                )
            )
        );
        return $form;
    }
    public function forUpdate($id){ 
    	$this->zone_id->setValue($id);
    	return $this;
    }
    
	public function populate(array $values){
		$return = parent::setDefaults($values);
		$model = new Application_Model_LocZones();
		if (!empty($values['parent_id'])){
			$parent =  $model->findById($values['parent_id']);
			$this->parentText->setValue($parent->name);
		}
        return $return;
    }
}